#include "Windows/mainwindow.h"
#include "Dialogs/degreedialog.h"
#include "Dialogs/rotationdialog.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent)
{
    setupUi(this);

//  UWAGA! Inicjalizowac okienka dialogowe (wskaznikowe) zerowym wskaznikiem!
    setupDialogs();

    glWidget = new GLWidget(this);
    setCentralWidget( glWidget );
}

MainWindow::~MainWindow()
{

}

void MainWindow::setupDialogs()
{
    degreeDialog   = 0;
    rotationDialog = 0;
}

void MainWindow::closeEvent(QCloseEvent *event)
{
//     if ( ConfirmDialog )
        event -> accept( );
//    else
//        event -> ignore( );
}

void MainWindow::on_actionCurveReduceDegree_triggered( )
{
    if(!degreeDialog)
    {
        degreeDialog = new DegreeDialog( this );
        connect( degreeDialog, SIGNAL( reduceDegree( int, int ) ),
                 glWidget,       SLOT( reduceDegree( int, int ) ) );
    }

    degreeDialog -> show( );
    degreeDialog -> raise( );
    degreeDialog -> activateWindow( );
}


void MainWindow::on_actionRotate_triggered()
{
    if(!rotationDialog)
    {
        rotationDialog = new RotationDialog(this);
//        connect(rotationDialog, SIGNAL(degreeChanged(int)),
//                glWidget,       SLOT(rotateCurve(int)));

    }

    rotationDialog->show();
    rotationDialog->raise();
    rotationDialog->activateWindow();
}
